
function submitComment() {
  var contents = jQuery('#form-add-comment #comment_content').val();
  
  jQuery.post(baseUrl+'/post_comments/add', { scsId: scsId, contents: contents }, function(data) {
    if (data == 'success') {
      loadComment(baseUrl+'/post_comments/list');
    } else if (data == 'failed') {
      alert('Co mot loi da xay ra.');
    }
  });
    
  return false;
}

function loadComment(url) {
  jQuery('#sc-comments').load(url, {
    scsId: scsId
  }).fadeIn('slow');
}

function sendMail() {  
  var title = jQuery('.email-wrapper #title').val();
  var sender = jQuery('.email-wrapper #sender').val();
  var email_from = jQuery('.email-wrapper #email_from').val();
  var email_to = jQuery('.email-wrapper #email_to').val();
  var contents = jQuery('.email-wrapper #contents').val();
  var path_send = jQuery('.email-wrapper #path_send').val();
  
  jQuery.post(baseUrl+'/send_mail', { title: title, sender: sender, email_from: email_from, email_to: email_to, contents: contents, path_send: path_send}, function(data) {
    if (data == 'success') {
      cancel();
    } else if (data == 'failed') {
      alert('Co mot loi da xay ra.');
    }
  });
  
  return false;
}

function cancel() {
  jQuery('.email-wrapper').hide('slow');
}

jQuery(document).ready(function() {
  jQuery(".icon-email").click(function() {
    jQuery('.email-wrapper').toggle('slow');
  });
});